package homework3;

import java.util.*;

/**
 * @classname:WhatTime
 * @description:
 * @author: Mr.Z
 * @date: 2020/12/14 19:26
 * @version: 0.1
 * @since:1.8
 */
public class WhatTime {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("请输入年");
        int year = input.nextInt();
        System.out.println("请输入月");
        int mounth = input.nextInt();
        System.out.println("请输入日");
        int day = input.nextInt();
        StringToWeek(year, mounth, day);
    }

    private static void StringToWeek(int year, int mounth, int day) {
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.YEAR, year);
        calendar.set(Calendar.MONTH, mounth - 1);
        calendar.set(Calendar.DATE, day);
        int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK) - 1;
        HashMap<Integer, String> hashMap = new HashMap<>();
        hashMap.put(1, "星期一");
        hashMap.put(2, "星期二");
        hashMap.put(3, "星期三");
        hashMap.put(4, "星期四");
        hashMap.put(5, "星期五");
        hashMap.put(6, "星期六");
        hashMap.put(7, "星期日");

        Set<Map.Entry<Integer, String>> entries = hashMap.entrySet();
        entries.forEach((entry) -> {
            if (entry.getKey().equals(dayOfWeek)) {
                System.out.println("当前日期为:" + entry.getValue());
            }
        });
    }
}
